/*
 * Copyright (C) 2011, EADS France
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 */

package xowl.interpreter.frontends.ntriples;

/**
 *
 * @author Laurent WOUTERS
 */
public class NTriplesLoader implements xowl.interpreter.frontends.Loader {
    static final String name = "N-Triples Loader";
    
    @Override public xowl.lang.owl2.Ontology loadOntology(xowl.utils.logging.Logger logger, String docName, java.io.Reader reader, xowl.interpreter.frontends.OntologyListener listener) {
        xowl.interpreter.backends.rdf.RDFRepository rdfRepo = new xowl.interpreter.backends.rdf.SimpleRDFRepository(logger);
        GraphLoader loader = new GraphLoader(rdfRepo.getDefaultEvaluator(), listener, rdfRepo.getGraph());
        loader.load(reader);
        xowl.lang.owl2.Ontology ontology = loader.getOntology();
        xowl.interpreter.backends.rdf.TranslatorRDF_OWL2 translator = new xowl.interpreter.backends.rdf.TranslatorRDF_OWL2(rdfRepo);
        for (xowl.lang.owl2.Axiom axiom : translator.translateOntology(rdfRepo.getDefaultEvaluator(), rdfRepo.getGraph(), ontology))
            listener.onAxiom(ontology, axiom);
        return ontology;
    }
    
    @Override public void loadQueries(xowl.utils.logging.Logger logger, String docName, java.io.Reader reader, xowl.interpreter.frontends.QueriesListener listener) {
        throw new java.lang.UnsupportedOperationException();
    }
}
